﻿#pragma once

#include "Protocol.h"
#include "Client.h"

typedef CMap<CString, LPCTSTR, Client*, Client*> OnlineUsers;

// 服务器
class Server: public CSocket {
    friend class Client;

    private: OnlineUsers mOnlineUsers;  // 在线用户列表

    public: Server();
    public: ~Server();
    private: void HandleFindUsers(FindUsersRequest*, Client*);
    private: void HandleProtocol(GomokuProtocol*);
    private: void HandleLogon(LogonRequest*, Client*);
    private: void HandleQuitGame(QuitGame*, Client*);
    private: virtual void OnAccept(int);
    private: void OnGetMessageFromClient(GomokuProtocol*, Client*);
    private: int SendData(Client*, GomokuProtocol*, int);
    public: BOOL Start();
};
